import taskpool from '@ohos.taskpool';
import { BasicDecoder } from '../BasicDecoder';

export class TelloDecoder extends BasicDecoder {
  public decode(buffer: ArrayBuffer){
    let str: string = String.fromCharCode.apply(null, new Uint8Array(buffer));
    let strArr = str.split(";");
    let map = new Map<string, number>();
    for (let i = 0; i < strArr.length; i++) {
      if (strArr[i] === "\r\n") //
        break;
      let keyVal = strArr[i].split(":");
      if (keyVal.length == 2) {
        map.set(keyVal[0], Number(keyVal[1]));
      }
    }
    return map;
  }
}
